package com.ocean.items.vegetables;

import com.ocean.config.GroupDefine;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.world.World;

import javax.annotation.Nonnull;

/**
 * 青草沙拉
 *
 * @author zhang
 * @since 2021/11/6
 */
public class GrassSalad extends Item {

    private static final Food FOOD = new Food.Builder().saturationMod(6)
            .nutrition(6).build();

    public GrassSalad() {
        super(new Properties().tab(GroupDefine.QUALITY_GROUP).food(FOOD).stacksTo(1));
    }

    /**
     * 物品被使用(吃掉)
     *
     * @param itemStack    物品堆
     * @param world        世界
     * @param livingEntity 活着的实体
     * @return ItemStack
     */
    @Nonnull
    @Override
    public ItemStack finishUsingItem(@Nonnull ItemStack itemStack, @Nonnull World world, @Nonnull LivingEntity livingEntity) {
        super.finishUsingItem(itemStack, world, livingEntity);
        return itemStack.isEmpty() ? new ItemStack(Items.BOWL) : itemStack;
    }
}
